package com.shuyao.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.shuyao.system.common.Result;
import com.shuyao.system.domain.entity.SysUser;
import com.shuyao.system.mapper.SysUserMapper;
import com.shuyao.system.service.ISysUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * <p>
 * 用户表 服务实现类
 * </p>
 *
 * @Author: yuzhiqin
 * @CreateTime: 2024-01-30
 */
@Service
@Slf4j
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements ISysUserService {


	@Override
	public Result<IPage<SysUser>> queryPageList(HttpServletRequest req, QueryWrapper<SysUser> queryWrapper, Integer pageSize, Integer pageNo) {
		Result<IPage<SysUser>> result = new Result<IPage<SysUser>>();
		Page<SysUser> page = new Page<SysUser>(pageNo, pageSize);
		IPage<SysUser> pageList = this.page(page, queryWrapper);

		result.setSuccess(true);
		result.setResult(pageList);
		//log.info(pageList.toString());
		return result;
	}


	@Transactional
	@Override
	public void saveUsers() {
		List<SysUser> list = list();
		System.out.println("changud1:"+list.size());

		SysUser sysUser = new SysUser();
		sysUser.setAvatar("dsfdfsd");
		sysUser.setDelFlag(0);
		sysUser.setEmail("dsds");
		save(sysUser);
		List<SysUser> list2 = list();
		System.out.println("changud2:"+list2.size());


		SysUser sysUser3 = new SysUser();
		sysUser3.setAvatar("dsfdfsd");
		sysUser3.setDelFlag(0);
		sysUser3.setEmail("dsds");
		save(sysUser3);
		List<SysUser> list23 = list();
		System.out.println("changud3:"+list23.size());
		throw new RuntimeException("e");

	}

}
